/**
 *******************************************************************************
 * @file  ov5640.h
 * @brief This file contains all the functions prototypes of the OV5640 driver
 *        library.
 @verbatim
   Change Logs:
   Date             Author          Notes
   2020-08-20       Zhangxl         First version
 @endverbatim
 *******************************************************************************
 * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
 *
 * This software component is licensed by HDSC under BSD 3-Clause license
 * (the "License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at:
 *                    opensource.org/licenses/BSD-3-Clause
 *
 *******************************************************************************
 */
#ifndef __OV5640_H__
#define __OV5640_H__

/* C binding of definitions if building with C++ compiler */
#ifdef __cplusplus
extern "C"
{
#endif

/*******************************************************************************
 * Include files
 ******************************************************************************/
#include "hc32_common.h"

/**
 * @addtogroup BSP
 * @{
 */

/**
 * @addtogroup Components
 * @{
 */

/**
 * @addtogroup OV5640
 * @{
 */

#if (BSP_OV5640_ENABLE == BSP_ON)

/*******************************************************************************
 * Global type definitions ('typedef')
 ******************************************************************************/

/*******************************************************************************
 * Global pre-processor symbols/macros ('#define')
 ******************************************************************************/
/**
 * @defgroup OV5640_Global_Macros OV5640 Global Macros
 * @{
 */

/**
 * @brief  OV5640 Chip ID
 */
#define OV5640_CHIPIDH              (0x300AU)
#define OV5640_CHIPIDL              (0x300BU)
/**
 * @}
 */

/**
 * @brief  OV5640 ID
 */
#define OV5640_ID                   (0x5640U)
/**
 * @}
 */

/**
 * @defgroup OV5640_Light_Control OV5640 Light Control
 */
#define OV5640_LIGHT_ON             (1U)
#define OV5640_LIGHT_OFF            (0U)
/**
 * @}
 */

/**
 * @}
 */

/*******************************************************************************
 * Global variable definitions ('extern')
 ******************************************************************************/

/*******************************************************************************
  Global function prototypes (definition in C source)
 ******************************************************************************/
/**
 * @defgroup OV5640_Global_Functions OV5640 Global Functions
 * @{
 */
void OV5640_Init(void);
uint16_t OV5640_ReadID(void);
void OV5640_RGB565_Mode(void);
void OV5640_SetOutSize(uint16_t u16X,
                        uint16_t u16Y,
                        uint16_t u16Width,
                        uint16_t u16Height);
void OV5640_LightControl(uint8_t u8Switch);
void OV5640_TestPattern(uint8_t u8Mode);

/* Implement the below functions for the specified BSP board */
en_result_t BSP_OV5640_Init(void);
en_result_t BSP_OV5640_ReadReg(uint16_t u16Reg,
                                uint8_t *pu8RxBuf,
                                uint32_t u32Len);
en_result_t BSP_OV5640_WriteReg(uint16_t u16Reg,
                                const uint8_t *pu8TxBuf,
                                uint32_t u32Len);

/**
 * @}
 */

#endif /* BSP_OV5640_ENABLE */

/**
 * @}
 */

/**
 * @}
 */

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __OV5640_H__ */

/*******************************************************************************
 * EOF (not truncated)
 ******************************************************************************/
